﻿<!DOCTYPE html>
<html>
  <head>
    <title>remuserpass</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <link href="resources/css/jquery-ui-themes.css" type="text/css" rel="stylesheet"/>
    <link href="resources/css/axure_rp_page.css" type="text/css" rel="stylesheet"/>
    <link href="data/styles.css" type="text/css" rel="stylesheet"/>
    <link href="files/remuserpass/styles.css" type="text/css" rel="stylesheet"/>
    <script src="resources/scripts/jquery-1.7.1.min.js"></script>
    <script src="resources/scripts/jquery-ui-1.8.10.custom.min.js"></script>
    <script src="resources/scripts/prototypePre.js"></script>
    <script src="data/document.js"></script>
    <script src="resources/scripts/prototypePost.js"></script>
    <!-- <script src="files/remuserpass/data.js"></script> -->
    <script type="text/javascript">
      $axure.utils.getTransparentGifPath = function() { return 'resources/images/transparent.gif'; };
      $axure.utils.getOtherPath = function() { return 'resources/Other.html'; };
      $axure.utils.getReloadPath = function() { return 'resources/reload.html'; };
    </script>
  </head>
  <body>
    <div id="base" class="">

      <!-- Unnamed (矩形) -->
      <div id="u114" class="ax_default _一级标题">
        <div id="u114_div" class=""></div>
        <div id="u114_text" class="text ">
          <p><span>重置用户密码</span></p>
        </div>
      </div>

      <!-- Unnamed (矩形) -->
      <div id="u115" class="ax_default _文本段落">
        <div id="u115_div" class=""></div>
        <div id="u115_text" class="text ">
          <p><span>输入手机号</span></p><p><span><br></span></p><p><span>旧密码</span></p><p><span>新密码</span></p><p><span>确认新密码</span></p><p><span><br></span></p><p><span><br></span></p><p><span><br></span></p>
        </div>
      </div>



      <!-- 搜索用户id表单 -->
      <!-- Unnamed (文本框) -->
      <div id="u116" class="ax_default text_field" title="请输入用户id">
        <input id="u116_input" type="text" value="" title="请输入用户id"/>
      </div>

      <!-- Unnamed (提交按钮) -->
      <div id="u117" class="ax_default html_button">
        <input type="button" value="搜索" onclick="finduser();"/>
      </div>
    <script>
      var userProblems = [];
      userProblems[0] = "你的小学老师名字是";
      userProblems[1] = "你的母亲名字是";
      userProblems[2] = "你的父亲名字是";
      userProblems[3] = "你小学的名字是";
      userProblems[4] = "你从小最好的伙伴名字是";

      var userState;
      var userPass;
      var userAnswer;
      var userId;
       function finduser(){
          userId = document.getElementById('u116_input').value;
          var userurl = "/BackstageUser/findUserById?userId="+userId+"";
            $.get(userurl,function (d){
              if(d != null){
                userState = d.userState;
                userPass = d.userPass;
                userAnswer = d.userAnswer;
                var userproblem = document.getElementById('userproblem');
                userproblem.innerText = userProblems[d.userProblemNo-1];
              }else{
                alert('查无此人');
              }
            })
        }
    </script>


      <!-- Unnamed (文本框) -->
      <div id="u118" class="ax_default text_field" title="请在此输入问题答案">
        <input id="u118_input" type="text" value="" title="请在此输入问题答案"/>
      </div>

      <!-- Unnamed (矩形) -->
      <div id="u119" class="ax_default label">
        <div id="u119_div" class=""></div>
        <div id="u119_text" class="text ">
          <p><span>问题</span></p>
        </div>
      </div>

      <!-- Unnamed (矩形) -->
      <div id="u120" class="ax_default label">
        <div id="u120_div" class=""></div>
        <div id="u120_text" class="text ">
          <p><span>问题答案</span></p>
        </div>
      </div>

      <!-- Unnamed (矩形) -->
      <div id="u121" class="ax_default label">
        <div id="u121_div" class=""></div>
        <div id="u121_text" class="text ">
          <p><span id="userproblem">我是一个问题</span></p>
        </div>
      </div>

      <!-- Unnamed (矩形) -->
      <div id="u122" class="ax_default label">
        <div id="u122_div" class=""></div>
        <div id="u122_text" class="text ">
          <p><span>用户名</span></p>
        </div>
      </div>

      <!-- Unnamed (文本框) -->
      <div id="u123" class="ax_default text_field" title="请在此输入旧密码">
        <input id="u123_input" type="text" value="" title="请在此输入旧密码" maxlength="10"/>
      </div>

      <!-- Unnamed (矩形) -->
      <div id="u124" class="ax_default label">
        <div id="u124_div" class=""></div>
        <div id="u124_text" class="text ">
          <p><span>旧密码</span></p>
        </div>
      </div>

      <!-- Unnamed (矩形) -->
      <div id="u125" class="ax_default label">
        <div id="u125_div" class=""></div>
        <div id="u125_text" class="text ">
          <p><span>新密码</span></p>
        </div>
      </div>

      <!-- Unnamed (矩形) -->
      <div id="u126" class="ax_default label">
        <div id="u126_div" class=""></div>
        <div id="u126_text" class="text ">
          <p><span>确认新密码</span></p>
        </div>
      </div>

      <!-- Unnamed (文本框) -->
      <div id="u127" class="ax_default text_field" title="请输入6-10位新密码">
        <input id="u127_input" type="text" value="" title="请输入6-10位新密码" maxlength="10"/>
      </div>

      <!-- Unnamed (文本框) -->
      <div id="u128" class="ax_default text_field" title="请确认新密码">
        <input id="u128_input" type="text" value="" title="请确认新密码" maxlength="10"/>
      </div>

      <!-- Unnamed (提交按钮) -->
      <div id="u129" class="ax_default html_button">
        <input id="u129_input" type="button" value="确认修改" onclick="remUserPass();"/>
      </div>


      <script>
        function remUserPass(){
          var userAnswers = document.getElementById('u118_input').value;
          var oldPass = document.getElementById('u123_input').value;
          var newPass = document.getElementById('u127_input').value;
          var relNewPass = document.getElementById('u128_input').value;
          if(userAnswer == userAnswers){
            if(userPass == oldPass){
              if(newPass == relNewPass){
                var myurl = "/BackstageUser/remUserPass?userId="+userId+"&userPass="+newPass+"";
                $.get(myurl,function(d){
                  if(1==d.affectedRows){
                    alert('修改成功');
                    window.location.href = './showuser.html';
                  }else{
                    alert('发生错误,请联系管理员');
                  }
                })
              }else{
                alert("两次密码不一致");
              }
            }else{
              alert("旧密码错误");
            }
          }else{
            alert("答案错误");
          }
        }
      </script>
    </div>
  </body>
</html>
